{% extends 'CHOMPSGIBundle:Incidentes:base.html.twig' %}

{% block actions %}			
<div class="well sidebar-nav"><div class="panel-group" id="accordion">  
    <b>
        FILTROS
        <i class="icon-filter" style="margin-top:3px;" ></i>
    </b>

    {{ form_start(form) }}
    <div class="panel panel-default">
        <div class="panel-heading"><h4 class="panel-title"><a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapse1" style="width: 100%;"> 
            <button class="btn dropdown-toggle" data-toggle="collapse" style="width: 100%;">
                {{ form.id.vars.label }}
                <span class="caret pull-right"></span>
            </button></a></h4>
        </div>
        <div id="collapse1" class="panel-collapse collapse in"><div class="panel-body">
            {{ form_errors(form.id) }}
            {{ form_widget(form.id) }}
            </div>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading"><h4 class="panel-title"><a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapse2" style="width: 100%;"> 
            <button class="btn dropdown-toggle" data-toggle="collapse" style="width: 100%;">
                {{ form.titulo.vars.label }}
                <span class="caret pull-right"></span>
            </button></a></h4>
        </div>
        <div id="collapse2" class="panel-collapse collapse"><div class="panel-body">
            {{ form_errors(form.titulo) }}
            {{ form_widget(form.titulo) }}
            </div>
        </div>
    </div>
<!--
    <div class="panel panel-default">
        <div class="panel-heading"><h4 class="panel-title"><a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapse3" style="width: 100%;"> 
            <button class="btn dropdown-toggle" data-toggle="collapse" style="width: 100%;">
                {{ form.empresa.vars.label }}
                <span class="caret pull-right"></span>
            </button></a></h4>
        </div>
        <div id="collapse3" class="panel-collapse collapse"><div class="panel-body">
            {{ form_errors(form.empresa) }}
            {{ form_widget(form.empresa) }}
            </div>
        </div>
    </div>
-->    
    <div class="panel panel-default">
        <div class="panel-heading"><h4 class="panel-title"><a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapse4" style="width: 100%;"> 
            <button class="btn dropdown-toggle" data-toggle="collapse" style="width: 100%;">
                {{ form.creador.vars.label }}
                <span class="caret pull-right"></span>
            </button></a></h4>
        </div>
        <div id="collapse4" class="panel-collapse collapse"><div class="panel-body">
            {{ form_errors(form.creador) }}
            {{ form_widget(form.creador) }}
            </div>
        </div>
    </div>
    
    <div class="panel panel-default">
        <div class="panel-heading"><h4 class="panel-title"><a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapse5" style="width: 100%;"> 
            <button class="btn dropdown-toggle" data-toggle="collapse" style="width: 100%;">
                {{ form.responsableSoporte.vars.label }}
                <span class="caret pull-right"></span>
            </button></a></h4>
        </div>
        <div id="collapse5" class="panel-collapse collapse"><div class="panel-body">
            {{ form_errors(form.responsableSoporte) }}
            {{ form_widget(form.responsableSoporte) }}
            </div>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading"><h4 class="panel-title"><a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapse6" style="width: 100%;"> 
            <button class="btn dropdown-toggle" data-toggle="collapse" style="width: 100%;">
                {{ form.estado.vars.label }}
                <span class="caret pull-right"></span>
            </button></a></h4>
        </div>
        <div id="collapse6" class="panel-collapse collapse"><div class="panel-body">
            {{ form_errors(form.estado) }}
            {{ form_widget(form.estado) }}
            </div>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading"><h4 class="panel-title"><a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapse7" style="width: 100%;"> 
            <button class="btn dropdown-toggle" data-toggle="collapse" style="width: 100%;">
                {{ form.grupoSoporte.vars.label }}
                <span class="caret pull-right"></span>
            </button></a></h4>
        </div>
        <div id="collapse7" class="panel-collapse collapse"><div class="panel-body">
            {{ form_errors(form.grupoSoporte) }}
            {{ form_widget(form.grupoSoporte) }}
            </div>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading"><h4 class="panel-title"><a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapse8" style="width: 100%;"> 
            <button class="btn dropdown-toggle" data-toggle="collapse" style="width: 100%;">
                PER&Iacute;ODO
                <span class="caret pull-right"></span>
            </button></a></h4>
        </div>
        <div id="collapse8" class="panel-collapse collapse"><div class="panel-body">
            {{ form_errors(form.periodo) }}
            {{ form_widget(form.periodo) }}
            </div>
        </div>
    </div>
    
        <div style="margin-top:20px; border-top: 1px solid #ddd; padding: 10px 0">
			<a class="btn pull-left" href="{{ path("incidentes_listarMio" ,{ 'page': 1 }) }}">
				Asignado a mi
			</a>
            {{ form_widget(form.filtrar, { 'attr': {'class': 'btn pull-right'} }) }}
        </div>

    </div>
    {{ form_end(form) }}
</div>
{% endblock %}

{% block content %}
    {{ parent() }}
    <div style="padding: 20px 0;">
		{% spaceless %}
			{% if 'EDITAR_INCIDENTE' in permisos %}
			   <a class="btn btn-success" href="{{ path("incidentes_nuevo") }}">Crear Incidente</a>
			{% endif %}
		{% endspaceless %}				
		<div class="btn descarga">
			<i class="icon-download-alt"></i>
			<a href="{{ path("incidentes_listarImprimir",{ 'page': 1 }) }}">
				Descargar como pdf
			</a>
		</div>
    </div>

    <table class="table table-condensed listado">
        <tr>
            <th>N&#176; Incidente</th>
            <th>Titulo</th>
            <th>Empresa</th>
            <th>Creado por</th>
            <th>Resp. Soporte</th>
            <th>Estado</th>
            <th>Fecha Creaci&oacute;n</th>
        </tr>
        {% for incidente in incidentes %}
            {% if incidente.estado.id == 2 %}
			<tr class="incidente-row green">
            {% else %}
				{% if incidente.estado.id == 3 %}
				<tr class="incidente-row yellow">
				{% else %}
					{% if incidente.estado.id == 1 %}
					<tr>
					{% else %}
						{% if incidente.estado.id == 5 %}
						<tr class="incidente-row red">
						{% else %}
							{% if incidente.estado.id == 4 %}
							<tr class="incidente-row blue">
							{% else %}
							<tr>
							{% endif %}
						{% endif %}
					{% endif %}
				{% endif %}
			{% endif %}
			    <td>{{incidente.id}}</a></td>
			    <td><a href="{{path('incidentes_ver',{ 'id': incidente.id })}}">{{incidente.titulo}}</a></td>
                <td>{{incidente.getEmpresa.getNombre | default("") }}</td>
                <td>{{incidente.getCreador.getLogin | default("") }}</td>
                <td>{{incidente.getResponsableSoporte.getLogin | default("DEBE SER ASIGNADO") }}</td>
                <td>{{incidente.getEstado.getNombre  | default("") }}</td>
                <td>{{incidente.fechaCreacion|date('Y-m-d H:i:s') | default("") }}</td>
          </tr>
        {% endfor %}
        <tr>
            <td colspan="9"> 
                {{ pagerfanta (incidentes, 'twitter_bootstrap_translated' , { 'prev_message' : 'Anterior', 'next_message': 'Siguiente'} ) }} 
            </td> 
        </tr>
    </table>

{% endblock %}
